<?php
require_once './buildCurl.php';
$res = json_decode(file_get_contents('php://input'), true);

$session = $res['session'];

$now_year = date('Y');

$url = 'http://211.82.48.36/student/teachingResources/gradeAndClassCurriculum/classJson?departmentNum=' . $res['dp'] . '&subjectNum=' . $res['value'] . '&yearNum=' . $res['year'];

$myCurl = new MyCurl($url, $session);
$result =  $myCurl->getResult();
$httpCode = $myCurl->getHttpCode();

if ($httpCode != 200) {
    $arr = array('err' => 1);
    exit(json_encode($arr));
}

$content = json_decode($result, true);

$result_arr_0 = [];
$result_arr_1 = [];

$result_arr_0[] = '未选择';
$result_arr_1[] = 0;

foreach ($content as $value0) {
    $name = $value0['className'];
    //专业名
    $code = $value0['classCode'];
    //专业号
    $result_arr_0[] = $name;
    $result_arr_1[] = $code;
}

$result_arr = array($result_arr_0, $result_arr_1);

$arr = array('err' => 0, 'class' =>  $result_arr_0, 'class_id' =>  $result_arr_1);
exit(json_encode($arr));
